﻿using UnityEngine;
using System.Collections;

//Minu katse teha "töötavat" relva. Õpetus, Mille järgi tegin: http://www.youtube.com/watch?v=7RtyA8j-_-E 


public class Gun : MonoBehaviour {

	public GameObject shot;
	public Transform spawn;
	public float fireRate;

	public GameObject muzzleFlash;
	public Transform muzzleFlashspawn;
	
	private float nextFire;
	
	public float Range = 5f;

	public void Shoot() {
		if (Time.time > nextFire)
		{
			nextFire = Time.time + fireRate;
			Instantiate(shot, spawn.position, spawn.rotation);
			Instantiate(muzzleFlash,muzzleFlashspawn.position, muzzleFlashspawn.rotation);
		}
	}

}
